package com.asset.dispoal.user.service;

import com.asset.dispoal.user.api.UserService;
import com.asset.dispoal.user.dto.BsLawyerAddRequest;
import com.asset.dispoal.user.dto.BsLawyerCourtRequest;
import com.asset.dispoal.user.dto.BsLawyerResponse;
import com.asset.dispoal.user.dto.BsLawyerUpdateRequest;
import com.asset.dispoal.user.dto.UserRequest;
import com.asset.dispoal.user.dto.UserResetPwdRequest;
import com.asset.dispoal.user.dto.UserResponse;
import com.asset.dispoal.user.service.commom.InsertLawyerCommand;
import com.asset.dispoal.user.service.commom.LoginCommand;
import com.asset.dispoal.user.service.commom.QueryLawyerByCourtCommand;
import com.asset.dispoal.user.service.commom.QueryLawyerDetailCommand;
import com.asset.dispoal.user.service.commom.ResetPwdUserCommand;
import com.asset.dispoal.user.service.commom.UpdateLawyerCommand;
import com.asset.dispoal.user.service.commom.UpdateUserCommand;
import com.asset.dispoal.user.service.commom.UserQueryPageCommand;
import com.asset.dispoal.user.service.commom.UserRegisterCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @author qr
 * @date 2022/1/21$
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    LoginCommand loginCommand;
    @Autowired
    UpdateUserCommand updateUserCommand;

    @Autowired
    UserQueryPageCommand userQueryPageCommand;

    @Autowired
    UserRegisterCommand userRegisterCommand;

    @Autowired
    QueryLawyerDetailCommand queryLawyerDetailCommand;

    @Autowired
    InsertLawyerCommand insertLawyerCommand;

    @Autowired
    UpdateLawyerCommand updateLawyerCommand;

    @Autowired
    QueryLawyerByCourtCommand queryLawyerByCourtCommand;

    @Autowired
    ResetPwdUserCommand resetPwdUserCommand;

    @Override
    public Result<UserResponse> login(UserRequest userRequest) {
        return loginCommand.execute(userRequest);
    }

    @Override
    public Result register(UserRequest userRequest) {
        return userRegisterCommand.execute(userRequest);
    }

    @Override
    public Result<PageVO<UserResponse>> queryPage(UserRequest userRequest) {
        final PageVO<UserResponse> execute = userQueryPageCommand.execute(userRequest);
        return Result.ok(execute);
    }

    @Override
    public Result update(UserRequest userRequest) {
        return updateUserCommand.execute(userRequest);
    }

    @Override
    public Result insertLawyer(BsLawyerAddRequest bsLawyerRequest) {
        return insertLawyerCommand.execute(bsLawyerRequest);
    }

    @Override
    public Result updateLawyer(BsLawyerUpdateRequest bsLawyerRequest) {
        return updateLawyerCommand.execute(bsLawyerRequest);
    }

    @Override
    public Result<BsLawyerResponse> queryLawyerDetail(String userId) {
        return queryLawyerDetailCommand.execute(userId);
    }

    @Override
    public Result<PageVO<BsLawyerResponse>> queryLawyerByCourt(BsLawyerCourtRequest request) {
        return queryLawyerByCourtCommand.execute(request);

    }

    @Override
    public Result resetPwd(UserResetPwdRequest request) {
        return resetPwdUserCommand.execute(request);
    }
}
